package org.example.controller;

import lombok.Getter;
import org.example.User;
import org.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller//做客户端请求处理及返回响应
@Getter
public class UserController {

    //注入方式一：属性上加@Autowired注解
    @Autowired
//    @Resource
    private UserService userService;

//    @Autowired
//    @Qualifier("zhangsan")
    @Resource(name = "li4")
    private User user;

    @Autowired
    private String s1;

//    @Autowired//构造方法参数userService，会注入容器中的该Bean对象
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }

//    @Autowired
//    @Resource
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
}
